package com.hnnou.freshmenappserver.dao;

import com.hnnou.freshmenappserver.bean.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface UserDao {
    @Select("select id, name, password,email,telephone,department,major from t_user")
    List<User> findAll();
    @Delete("delete from t_user where id=#{id}")
    int deleteById(int id);
    @Update("update t_user set  name=#{name} ,password=#{password} " +
            ",email=#{email}  ,telephone=#{telephone} " +
            ",department=#{department},  major=#{major}" +
            " where id=#{id} ")
    int update(User user);
    @Insert("insert into t_user(name, password,email,telephone,department,major)"+
            " values(#{name},#{password},#{email},#{telephone},#{department},#{major})")
    int insert(User user);

    @Select("select * from t_user where id=#{id}")
    User selectById(int id);
    @Insert("insert into t_user(name, password,email,telephone,department,major)"+
            " values(#{name},#{password},#{email},#{telephone},#{department},#{major})")
    public Integer register(User user);
    @Select("select * from t_user where name=#{name} and password=#{password}")
    public User login(User user);


}
